package marmalius;
public class Cooking {
	
	public Cooking() {
		
	}
	public int CookID = 0, cookz = 0, CookTime = 0;

	public void CookINT(int Id, int ID) {
		client c = (client) PlayerHandler.getInstance().getPlayer(ID);
		c.isCooking = true;
		c.sendFrame246(8886, 250, -1);
		c.sendFrame246(8885, 250, -1);
		c.sendFrame246(8884, 250, Id);
		c.sendFrame126("", 8887);
		c.sendFrame126("", 8890);
		c.sendFrame126("", 8894);
		c.sendFrame126("", 8891);
		c.sendFrame126("You are about to cook a " + c.getItemName(Id) + ".", 8898);
		c.sendFrame126("", 8895);  
		c.sendFrame164(8880);
	}		

	public void stillcook(int ID) {
		//client c = (client) PlayerHandler.getInstance().getPlayer(ID);
		if (CookID == 1)
			cook(1, 0, 321, 319, 323, 20, "Anchovies", true, ID);
		else if (CookID == 2)
			cook(1, 0, 317, 315, 323, 15, "Shrimps", true, ID);
		else if (CookID == 3)
			cook(10, 9, 359, 361, 367, 35, "Tuna", true, ID);
		else if (CookID == 4)
			cook(20, 19, 377, 379, 381, 45, "Lobster", true, ID);
		else if (CookID == 5)
			cook(33, 32, 363, 365, 367, 50, "Bass", true, ID);
		else if (CookID == 6)
			cook(45, 44, 371, 373, 375, 60, "Swordfish", true, ID);
		else if (CookID == 7)
			cook(60, 59, 7944, 7946, 7948, 70, "Monk Fish", true, ID);
		else if (CookID == 8)
			cook(80, 79, 383, 385, 387, 85, "Shark", true, ID);
		else if (CookID == 9)
			cook(82, 81, 395, 397, 399, 100, "Sea Turtle", true, ID);
		else if (CookID == 10)
			cook(99, 98, 389, 391, 393, 110, "Manta Ray", true, ID);
	}
	
	public void cook(int required, int requiredz, int id, int succ, int fail, int xp, String name, boolean burnable, int ID) {
		client c = (client) PlayerHandler.getInstance().getPlayer(ID);
		int Percent = 25 + (c.playerLevel[7] - required / 2);
		int Chance = (int) (java.lang.Math.random() * 100);
		if (c.playerLevel[7] >= required && c.IsItemInBag(id) == true) {
			if (c.CookTime <= 1) {
				c.startAnimation(883);
				c.deleteItem(id, c.GetItemSlot(id), 1);
				c.CookTime = 8;
				c.closeInterface();
				if (!burnable) {
					Chance = Percent;
				}
				if (Chance <= Percent) {
					c.addItem(succ, 1);
					c.addSkillXP(xp * 2, 7);
					c.sendMessage("You successfully cook the " + name + ".");
				}
				else {
					c.addItem(fail, 1);
					c.sendMessage("You accidentally burn The " + name + ".");
				}
			}
		} else if (c.playerLevel[7] <= requiredz) {
			c.sendMessage("You need a cooking level of " + required + " to cook "+name+".");
		}
	}
	
	public void COOKTHEMNOW(int useItemID, int atObjectID, int ID) {
		//client c = (client) PlayerHandler.getInstance().players[ID];
		if (useItemID == 321 && atObjectID == 2728) {
			CookID = 1;
			cookz = 1;
			CookINT(321, ID);
		}
		else if (useItemID == 317 && atObjectID == 2728) {
			CookID = 2;
			CookINT(317, ID);
			cookz = 2;
		}
		else if (useItemID == 359 && atObjectID == 2728) {
			CookID = 3;
			CookINT(359, ID);
			cookz = 3;
		}
		else if (useItemID == 377 && atObjectID == 2728) {
			CookID = 4;
			CookINT(377, ID);
			cookz = 4;
		}
		else if (useItemID == 363 && atObjectID == 2728) {
			CookID = 5;
			CookINT(363, ID);
			cookz = 5;
		}
		else if (useItemID == 371 && atObjectID == 2728) {
			CookID = 6;
			CookINT(371, ID);
			cookz = 6;
		}
		else if (useItemID == 7944 && atObjectID == 2728) {
			CookID = 7;
			CookINT(7944, ID);
			cookz = 7;
		}
		else if (useItemID == 383 && atObjectID == 2728) {
			CookID = 8;
			CookINT(383, ID);
			cookz = 8;
		}
		else if (useItemID == 395 && atObjectID == 2728) {
			CookID = 9;
			CookINT(395, ID);
			cookz = 9;
		}
		else if (useItemID == 389 && atObjectID == 2728) {
			CookID = 10;
			CookINT(389, ID);
			cookz = 10;
		}
	}
	
	public void orMaybeNow(int ID) {
		client c = (client) PlayerHandler.getInstance().getPlayer(ID);
		if (cookz == 1) {
			c.CookTime = 1;
			cook(1, 0, 321, 319, 323, 20, "Anchovies", true, ID);
		}
		if (cookz == 2) {
			c.CookTime = 1;
			cook(1, 0, 317, 315, 323, 15, "Shrimps", true, ID);
		}
		if (cookz == 3) {
			c.CookTime = 1;
			cook(10, 9, 359, 361, 367, 35, "Tuna", true, ID);
		}
		if (cookz == 4) {
			c.CookTime = 1;
			cook(20, 19, 377, 379, 381, 45, "Lobster", true, ID);
		}
		if (cookz == 5) {
			c.CookTime = 1;
			cook(33, 32, 363, 365, 367, 50, "Bass", true, ID);
		}
		if (cookz == 6) {
			c.CookTime = 1;
			cook(45, 44, 371, 373, 375, 60, "Swordfish", true, ID);
		}
		if (cookz == 7) {
			c.CookTime = 1;
			cook(60, 59, 7944, 7946, 7948, 70, "Monk Fish", true, ID);
		}
		if (cookz == 8) {
			c.CookTime = 1;
			cook(80, 79, 383, 385, 387, 85, "Shark", true, ID);
		}
		if (cookz == 9) {
			c.CookTime = 1;
			cook(82, 81, 395, 397, 399, 100, "Sea Turtle", true, ID);
		}
		if (cookz == 10) {
			c.CookTime = 1;
			cook(99, 98, 389, 391, 393, 110, "Manta Ray", true, ID);
		}
		if (cookz == 11) {
			if (c.playerHasItemAmount(3702, 1) == false && c.playerHasItemAmount(771, 1) == false) {
				c.closeInterface();
				c.sendMessage("You need Special bow string and Dark wood branch to make this bow.");
			}
			else if (c.playerHasItemAmount(3702, 1) && c.playerHasItemAmount(771, 1) && c.playerLevel[9] >= 99) {
				c.pEmote = 885;
				c.deleteItem(771, c.GetItemSlot(771), 1);
				c.deleteItem(3702, c.GetItemSlot(3702), 1);
				c.addItem(4827, 1);
				c.addSkillXP((100 * c.playerLevel[9]), 9);
			}
			else if (c.playerLevel[9] <= 98) {
				c.closeInterface();
				c.sendMessage("You need fletching level of 99 to make this bow.");
			}
		}
	}

	public void process() {
		if (CookTime > 0) {
			CookTime -= 1;
		}
	}
}
